#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 1000100;
int n;
int a[N],b[N],fa[N],fb[N];
long long sum_a[N],sum_b[N];
bool flag;

void print(int a,int b)
{
    printf("%d\n",b-a);
    for(int i=a+1; i<=b; i++)
        printf("%d ",i);
    printf("\n");
}

void cal(int a[], int b[], long long sum_a[], long long sum_b[])
{
    fa[0] = fb[0] = 0;
    for(int i=1; i<=n; i++)
        fa[i]=fb[i]=-1;
    for(int i=1; i<=n; i++)
    {
        int j = lower_bound(sum_b, sum_b+n+1, sum_a[i]) - sum_b;
        int v = sum_b[j] - sum_a[i];
        if(fa[v] == -1){
            fa[v]=i;
            fb[v]=j;
        }else{
            if(flag){
                print(fa[v],i);
                print(fb[v],j);
            }else{
                print(fb[v],j);
                print(fa[v],i);
            }
            return;
        }
    }
}
int main(int argc, char **argv)
{
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d", &a[i]);
        sum_a[i] = sum_a[i-1]+a[i];
    }
    for(int i=1; i<=n; i++){
        scanf("%d",&b[i]);
        sum_b[i]=sum_b[i-1]+b[i];
    }
    flag = sum_a[n] <= sum_b[n];
    if(flag){
        cal(a, b, sum_a, sum_b);
    }else{
        cal(b, a, sum_b, sum_a);
    }
    return 0;
}
